﻿using System;
using System.Globalization;
using System.IO;
using System.Web.Mvc;

namespace IFPRJ.EF.Components
{
    public class IFWebRazorViewEngine : System.Web.Mvc.RazorViewEngine
    {

        public IFWebRazorViewEngine(string themeName)
        {
            string AreaFolder = "Areas";
            string ThemeName = themeName ?? "Default";
            
            base.MasterLocationFormats = new string[] {
				"~/Themes/" + ThemeName + "/Views/Shared/{0}.cshtml",
				"~/Themes/" + ThemeName + "/Views/{1}/{0}.cshtml",
                "~/Views/Shared/{0}.cshtml",
                "~/Views/{1}/{0}.cshtml"
			};

            base.AreaMasterLocationFormats = new string[] {
				"~/Themes/" + ThemeName + "/" + AreaFolder + "/{2}/Views/Shared/{0}.cshtml",
				"~/Themes/" + ThemeName + "/" + AreaFolder + "/{2}/Views/{1}/{0}.cshtml",
                "~/" + AreaFolder + "/{2}/Views/Shared/{0}.cshtml",
                "~/" + AreaFolder + "/{2}/Views/{1}/{0}.cshtml"
			};
           
            base.ViewLocationFormats = new string[] {
				"~/Themes/" + ThemeName + "/Views/{1}/{0}.cshtml",
				"~/Themes/" + ThemeName + "/Views/Shared/{0}.cshtml",
                "~/Views/{1}/{0}.cshtml",
                "~/Views/Shared/{0}.cshtml",
                "~/Views/Home/Index.cshtml"
			};

            base.AreaViewLocationFormats = new string[] {
				"~/Themes/" + ThemeName + "/" + AreaFolder + "/{2}/Views/{1}/{0}.cshtml",
				"~/Themes/" + ThemeName + "/" + AreaFolder + "/{2}/Views/Shared/{0}.cshtml",
                "~/" + AreaFolder + "/{2}/Views/{1}/{0}.cshtml",
                "~/" + AreaFolder + "/{2}/Views/Shared/{0}.cshtml"
			};

            base.PartialViewLocationFormats = base.ViewLocationFormats;
            base.AreaPartialViewLocationFormats = base.AreaViewLocationFormats;
        }

    }
}
